var times = 1
var ctx = 1
var md1 = (ctx, next) => {
  // console.log(next.toString())
  // () => {
  //   return Promise.resolve(
  //     md2(ctx, () => {

  //     })
  //   )
  // }
  times++
  console.log('md1ctx', times)
  return next()
}

var md2 = (ctx, next) => {
 times = times *3
 console.log('md2ctx', times)
 return next()
}

var md3 = (ctx, next) => {
  times = times / 2
  return times
}

var p = Promise.resolve(
  md1(ctx, () => {
    return Promise.resolve(
      md2(ctx, () => {
        return Promise.resolve(md3(ctx, () => {}))
      })
    )
  })
)

p.then(ctx => {
  console.log('Final ctx', ctx)
})

// var p1 = Promise.resolve(Promise.resolve(2))
// console.log(p1.then(res => console.log(res)))